"""
背景/活动区分模块API路由
"""
from fastapi import APIRouter, Query
from app.core.response import create_response
from app.services.mock_data import mock_generator

router = APIRouter()


@router.get("", summary="获取完整数据")
async def get_background_activity_data():
    """
    获取背景/活动区分模块的所有数据
    """
    data = mock_generator.generate_background_activity_data()
    return create_response(data=data)


@router.get("/classification", summary="获取实时分类统计")
async def get_classification():
    """
    获取背景/活动人流实时分类统计
    """
    full_data = mock_generator.generate_background_activity_data()
    data = full_data["flowClassification"]
    return create_response(data=data)


@router.get("/trend", summary="获取趋势数据")
async def get_trend(
    period: str = Query(
        default="24h", regex="^(24h|7d|30d)$", description="时间段: 24h, 7d, 30d"
    )
):
    """
    获取背景/活动人流趋势数据

    Args:
        period: 时间段,可选值: 24h(24小时), 7d(7天), 30d(30天)
    """
    full_data = mock_generator.generate_background_activity_data()
    data = full_data["timeSeriesData"]
    return create_response(data=data)


@router.get("/clusters", summary="获取聚类数据")
async def get_clusters():
    """
    获取DBSCAN聚类分析结果
    """
    full_data = mock_generator.generate_background_activity_data()
    data = full_data["clusterData"]
    return create_response(data=data)


@router.get("/heatmap", summary="获取活动热力图")
async def get_activity_heatmap():
    """
    获取活动区域热力图数据
    """
    full_data = mock_generator.generate_background_activity_data()
    data = full_data["activityHeatmap"]
    return create_response(data=data)


@router.get("/features", summary="获取特征重要性")
async def get_feature_importance():
    """
    获取分类特征重要性
    """
    full_data = mock_generator.generate_background_activity_data()
    data = full_data["featureImportance"]
    return create_response(data=data)


@router.get("/rules", summary="获取分类规则")
async def get_decision_rules():
    """
    获取决策树分类规则
    """
    full_data = mock_generator.generate_background_activity_data()
    data = full_data["decisionRules"]
    return create_response(data=data)
